package com.itgaoshu.hospitalproject.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itgaoshu.hospitalproject.bean.Record;
import com.itgaoshu.hospitalproject.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("record")
public class RecordController {
    @Autowired
    private RecordService recordService;
    @RequestMapping("selrecord")
    @ResponseBody
    public Object selrecord(Record record, Integer page, Integer limit) {
        PageHelper.startPage(page, limit);
        List<Record> selrecord = recordService.selrecord(record);
        PageInfo pageInfo = new PageInfo(selrecord);
        Map<String, Object> drugstoresData = new HashMap<String, Object>();
        drugstoresData.put("code", 0);
        drugstoresData.put("msg", "");
        drugstoresData.put("count", pageInfo.getTotal());
        drugstoresData.put("data", pageInfo.getList());
        return drugstoresData;
    }

}
